#include<bits/stdc++.h>
using namespace std;
namespace IO
{
	char buff[1<<21],*p1=buff,*p2=buff;
	char getch(){return p1==p2&&(p2=((p1=buff)+fread(buff,1,1<<21,stdin)),p1==p2)?EOF:*p1++;}
	template<typename T>void read(T &x){char ch=getch();int fl=1;x=0;while(ch>'9'||ch<'0'){if(ch=='-')fl=-1;ch=getch();}while(ch<='9'&&ch>='0'){x=x*10+ch-48;ch=getch();}x*=fl;}
	template<typename T>void read_s(T &x){x="";char ch=getch();while(ch<'a'||ch>'z')ch=getch();while(ch>='a'&&ch<='z'){x+=ch;ch=getch();}}
	template<typename T,typename ...Args>void read(T &x,Args& ...args){read(x);read(args...);}
	char obuf[1<<21],*p3=obuf;
	void putch(char ch) {if(p3-obuf<(1<<21))*p3++=ch;else fwrite(obuf,p3-obuf,1,stdout),p3=obuf,*p3++=ch;}
	char ch[100];
	template<typename T>void write(T x) {if(!x)return putch('0');if(x<0)putch('-'),x*=-1;int top=0;while(x)ch[++top]=x%10+48,x/=10;while(top)putch(ch[top]),top--;}
	template<typename T,typename ...Args>void write(T x,Args ...args) {write(x);write(args...);}
	void put(string s){for(int i=0;i<s.size();i++)putch(s[i]);}
	void flush(){fwrite(obuf,p3-obuf,1,stdout);}
}
using namespace IO;
int n,m,a[114514],p[114514],c[114514];
int ans,cnt;
#define ll unsigned long long
ll Pow[114514],h[114514],h1[114514];
inline ll calc(int l,int r){return h[r]-h[l-1]*Pow[r-l+1];}
inline ll calc1(int l,int r){return h1[l]-h1[r+1]*Pow[r-l+1];}
void dfs(int st)
{
	if(st>n)
	{
		for(int i=1;i<=n;i++) h[i]=h[i-1]*131+p[i];
		for(int i=n;i;i--) h1[i]=h1[i+1]*131+p[i];
		int res=0;
		for(int i=1;i<=n;i++)
			for(int j=i;j<=n;j++)
				if(calc(i,(i+j>>1))==calc1((i+j>>1)+((j-i+1)%2==0),j)) ++res;
		if(res==ans) ++cnt;
		if(res>ans) ans=res,cnt=1;
		return;
	}
	for(int i=1;i<=m;i++) if(c[a[i]]) p[st]=a[i],--c[a[i]],dfs(st+1),++c[a[i]];
}
int main()
{
	freopen("palindrome.in","r",stdin);
	freopen("palindrome.out","w",stdout);
	read(n);
	Pow[0]=1;
	for(int i=1;i<=n;i++) Pow[i]=Pow[i-1]*131;
	for(int i=1;i<=n;i++) read(a[i]),++c[a[i]];
	sort(a+1,a+n+1);
	m=unique(a+1,a+n+1)-a-1;
	dfs(1);
	write(ans),putch(' '),write(cnt);
	flush();
	return 0;
}
/*
5
1 1 2 2 3
*/
